import * as types from './../constants/ActionTypes';

/*
 * 用户注册
 ================================================================*/
export function register({phone, captcha, password, deviceid, baidu_devicetype, baiduid} = {}) {
    return (dispatch) => {

        let payload = {
            register_status: 0,
            message: '加载中',
            phone : phone,
            password : password
        };
        
        dispatch({
            payload, 
            type: [types.REGISTER, types.REGISTER_SUCCESS, types.REGISTER_FAILURE],
            meta: {
                fetch: [
                    `members/reg`, {
                        method: "POST",
                        body: `phone=${phone}&captcha=${captcha}&password=${password}&deviceid=${deviceid}&baidu_devicetype=${baidu_devicetype}&baiduid=${baiduid}`
                    }
                ]
            }
        });
    };
}
